{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Advanced VQE usage\n",
    "\n",
    "There exist several parameters for configuring and using more advanced [VQE](https://qiskit.org/documentation/stubs/qiskit.aqua.algorithms.VQE.html) capabilities. This tutorial will cover the parameters such as `initial_point`, `expectation` and `gradient`.\n",
    "\n",
    "It will also cover advanced simulator use such as using Aer with the Matrix Product State method."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "from qiskit import BasicAer\n",
    "from qiskit.aqua.operators import X, Z, I\n",
    "from qiskit.aqua import QuantumInstance, aqua_globals\n",
    "from qiskit.aqua.algorithms import VQE\n",
    "from qiskit.aqua.components.optimizers import SLSQP\n",
    "from qiskit.circuit.library import TwoLocal"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Here we will use the same operator as used in the other VQE algorithms tutorials."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "H2_op = (-1.052373245772859 * I ^ I) + \\\n",
    "        (0.39793742484318045 * I ^ Z) + \\\n",
    "        (-0.39793742484318045 * Z ^ I) + \\\n",
    "        (-0.01128010425623538 * Z ^ Z) + \\\n",
    "        (0.18093119978423156 * X ^ X)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Initial point\n",
    "\n",
    "The `initial_point` parameter allows the optimization to begin at the given point, where the point is a list of parameters that will configure the variational form. By default the initial point is `None` which means that VQE will choose one. The choice in in this case is if the supplied variational form has a preferred point, based on the initial state provided to it, then this will be chosen, otherwise a random initial point that fits with any bounds the variational has will be chosen. If an initial point is supplied it will take priority though and be used - note though it must match in length to the number of parameters in the variational form circuit.\n",
    "\n",
    "Why to use a initial point? One reason would be if you have guess a reasonable starting point for the problem or perhaps know have information from a prior experiment.\n",
    "\n",
    "To demonstrate the use let's first simply repeat the first working example from the [algorithms introduction](01_algorithms_introduction.ipynb#A-complete-working-example) tutorial to get a solution's optimal point."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "{   'cost_function_evals': 72,\n",
      "    'eigenstate': array([-9.55448660e-05+2.12037105e-17j,  9.93766273e-01+2.25293943e-16j,\n",
      "       -1.11483565e-01+1.52657541e-16j, -1.77521351e-05+3.71607315e-17j]),\n",
      "    'eigenvalue': (-1.857275017559769+0j),\n",
      "    'optimal_parameters': {   Parameter(θ[0]): 4.296520551468743,\n",
      "                              Parameter(θ[1]): 4.426962086704216,\n",
      "                              Parameter(θ[2]): 0.5470753710293924,\n",
      "                              Parameter(θ[3]): 6.09294789784282,\n",
      "                              Parameter(θ[4]): -2.598325857134344,\n",
      "                              Parameter(θ[5]): 1.5683261371389359,\n",
      "                              Parameter(θ[6]): -4.717618235040379,\n",
      "                              Parameter(θ[7]): 0.3602072316165878},\n",
      "    'optimal_point': array([ 4.29652055,  4.42696209,  0.54707537,  6.0929479 , -2.59832586,\n",
      "        1.56832614, -4.71761824,  0.36020723]),\n",
      "    'optimal_value': -1.857275017559769,\n",
      "    'optimizer_evals': 72,\n",
      "    'optimizer_time': 1.2399418354034424}\n"
     ]
    }
   ],
   "source": [
    "from qiskit.aqua import aqua_globals\n",
    "seed = 50\n",
    "aqua_globals.random_seed = seed\n",
    "qi = QuantumInstance(BasicAer.get_backend('statevector_simulator'), seed_transpiler=seed, seed_simulator=seed)\n",
    "\n",
    "ansatz = TwoLocal(rotation_blocks='ry', entanglement_blocks='cz')\n",
    "slsqp = SLSQP(maxiter=1000)\n",
    "vqe = VQE(operator=H2_op, var_form=ansatz, optimizer=slsqp, quantum_instance=qi)\n",
    "result = vqe.run()\n",
    "\n",
    "import pprint\n",
    "pp = pprint.PrettyPrinter(indent=4)\n",
    "pp.pprint(result)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Now we can take the `optimal_point` from the above result and use it as the `initial_point` here."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "{   'cost_function_evals': 10,\n",
      "    'eigenstate': array([-9.55448660e-05+2.12037105e-17j,  9.93766273e-01+2.25293943e-16j,\n",
      "       -1.11483565e-01+1.52657541e-16j, -1.77521351e-05+3.71607315e-17j]),\n",
      "    'eigenvalue': (-1.857275017559769+0j),\n",
      "    'optimal_parameters': {   Parameter(θ[1]): 4.426962086704216,\n",
      "                              Parameter(θ[0]): 4.296520551468743,\n",
      "                              Parameter(θ[4]): -2.598325857134344,\n",
      "                              Parameter(θ[6]): -4.717618235040379,\n",
      "                              Parameter(θ[3]): 6.09294789784282,\n",
      "                              Parameter(θ[2]): 0.5470753710293924,\n",
      "                              Parameter(θ[5]): 1.5683261371389359,\n",
      "                              Parameter(θ[7]): 0.3602072316165878},\n",
      "    'optimal_point': array([ 4.29652055,  4.42696209,  0.54707537,  6.0929479 , -2.59832586,\n",
      "        1.56832614, -4.71761824,  0.36020723]),\n",
      "    'optimal_value': -1.857275017559769,\n",
      "    'optimizer_evals': 10,\n",
      "    'optimizer_time': 0.27449989318847656}\n"
     ]
    }
   ],
   "source": [
    "initial_pt = result.optimal_point\n",
    "\n",
    "aqua_globals.random_seed = seed\n",
    "qi = QuantumInstance(BasicAer.get_backend('statevector_simulator'), seed_transpiler=seed, seed_simulator=seed)\n",
    "\n",
    "ansatz = TwoLocal(rotation_blocks='ry', entanglement_blocks='cz')\n",
    "slsqp = SLSQP(maxiter=1000)\n",
    "vqe = VQE(operator=H2_op, var_form=ansatz, optimizer=slsqp, initial_point=initial_pt, quantum_instance=qi)\n",
    "result1 = vqe.run()\n",
    "\n",
    "pp.pprint(result1)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Here we see that result was arrived at much more quickly where `optimizer_evals` is 10 versus 72 when it started from a random value when the initial point was not supplied (default of None).\n",
    "\n",
    "Where this becomes useful for examples where we the solution to one problem can be used to for a guess for the solution to a very close similar problem. Chemistry is very good example where we change the inter-atomic distance(s) of molecule to plot a dissociation profile. When the distance changes are small we expect the solution to still be nearby the prior one. One technique is to simply use the optimal point from one solution as the starting point for the next step. Now more complex techniques are possible that do some extrapolation to compute an initial position based on prior solution(s) rather than directly use the prior solution. The Qiskit Chemistry [sampling_potential_energy_surfaces](../chemistry/05_Sampling_potential_energy_surfaces.ipynb#Extrapolation) tutorial shows such bootstrapping and extrapolation."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Expectation\n",
    "\n",
    "The energy of the Hamiltonian operator that VQE is working on is the expectation value when evaluated with the parameterized variational form. To compute the expectation value VQE uses an instance of an [expectation](https://qiskit.org/documentation/apidoc/qiskit.aqua.operators.expectations.html) object. Such an instance may be supplied via the `expectation` parameter, or in the default case, where it has a value of `None`, VQE will use the [ExpectationFactory](https://qiskit.org/documentation/stubs/qiskit.aqua.operators.expectations.ExpectationFactory.html) to create itself a suitable instance based on the supplied backend.\n",
    "\n",
    "For most cases letting VQE create a suitable instance is sufficient. However the Qiskit Aer qasm_simulator supports a snapshot instruction that can be used in conjunction with the operator expectation computation. If used then the outcome is ideal, i.e. like the statevector simulator, and has no shot noise. Since people normally choose the qasm_simulator to have shot noise (sampling noise), and be more like a real-device outcome, VQE has an `include_custom` flag that is passed on to the ExpectationFactory. When using Aer qasm simulator, and this is set `True`, the factory will return `AerPauliExpectation`  which uses the snapshot instruction, when `False`, default, then the regular `PauliExpectation` is returned.\n",
    "\n",
    "The following example shows `include_custom=True` where the outcome matches the statevector simulator. In fact it can be better/faster to do this than use the statevector_simulator directly. This is because in the latter case when the Hamiltonian is a sum of Paulis it must be converted to matrix form, and this is avoided when using the snapshot instruction done when include_custom is True."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "{   'cost_function_evals': 72,\n",
      "    'eigenstate': {'01': 1008, '10': 16},\n",
      "    'eigenvalue': (-1.8572750175597519+0j),\n",
      "    'optimal_parameters': {   Parameter(θ[0]): 4.296520463599476,\n",
      "                              Parameter(θ[1]): 4.426962139199476,\n",
      "                              Parameter(θ[2]): 0.5470754235069875,\n",
      "                              Parameter(θ[3]): 6.092947836794945,\n",
      "                              Parameter(θ[4]): -2.5983258956331645,\n",
      "                              Parameter(θ[5]): 1.568326000491598,\n",
      "                              Parameter(θ[6]): -4.717618128585369,\n",
      "                              Parameter(θ[7]): 0.3602072910298268},\n",
      "    'optimal_point': array([ 4.29652046,  4.42696214,  0.54707542,  6.09294784, -2.5983259 ,\n",
      "        1.568326  , -4.71761813,  0.36020729]),\n",
      "    'optimal_value': -1.8572750175597519,\n",
      "    'optimizer_evals': 72,\n",
      "    'optimizer_time': 1.2052154541015625}\n"
     ]
    }
   ],
   "source": [
    "from qiskit import Aer\n",
    "\n",
    "aqua_globals.random_seed = seed\n",
    "qi = QuantumInstance(Aer.get_backend('qasm_simulator'), seed_transpiler=seed, seed_simulator=seed)\n",
    "\n",
    "ansatz = TwoLocal(rotation_blocks='ry', entanglement_blocks='cz')\n",
    "slsqp = SLSQP(maxiter=1000)\n",
    "vqe = VQE(operator=H2_op, var_form=ansatz, optimizer=slsqp, quantum_instance=qi, include_custom=True)\n",
    "result = vqe.run()\n",
    "\n",
    "pp.pprint(result)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "In case you have doubts here is the qasm_simulator again but include_custom has been left to default to False. The optimization ended abruptly, presumably due to the shot noise confusing the SLSQP optimizer. The optimal value can be seen to be wrong too, i.e. -1.098 versus the correct -1.857."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "{   'cost_function_evals': 10,\n",
      "    'eigenstate': {'00': 620, '01': 244, '10': 159, '11': 1},\n",
      "    'eigenvalue': (-1.0987888676631705+0j),\n",
      "    'optimal_parameters': {   Parameter(θ[5]): 1.8462931831829383,\n",
      "                              Parameter(θ[6]): -5.466043598406607,\n",
      "                              Parameter(θ[7]): 0.6984088030463615,\n",
      "                              Parameter(θ[2]): 0.6019852007557844,\n",
      "                              Parameter(θ[1]): 4.19301252102391,\n",
      "                              Parameter(θ[0]): 3.611860069224077,\n",
      "                              Parameter(θ[4]): -3.3070470445355764,\n",
      "                              Parameter(θ[3]): 5.949536809130025},\n",
      "    'optimal_point': array([ 3.61186007,  4.19301252,  0.6019852 ,  5.94953681, -3.30704704,\n",
      "        1.84629318, -5.4660436 ,  0.6984088 ]),\n",
      "    'optimal_value': -1.0987888676631705,\n",
      "    'optimizer_evals': 10,\n",
      "    'optimizer_time': 0.5309410095214844}\n"
     ]
    }
   ],
   "source": [
    "aqua_globals.random_seed = seed\n",
    "qi = QuantumInstance(Aer.get_backend('qasm_simulator'), seed_transpiler=seed, seed_simulator=seed)\n",
    "\n",
    "ansatz = TwoLocal(rotation_blocks='ry', entanglement_blocks='cz')\n",
    "slsqp = SLSQP(maxiter=1000)\n",
    "vqe = VQE(operator=H2_op, var_form=ansatz, optimizer=slsqp, quantum_instance=qi)\n",
    "result = vqe.run()\n",
    "\n",
    "pp.pprint(result)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Changing the optimizer to SPSA, which is designed to work in noisy environments, gets us a better result. Though the noise has affected the outcome so it's not as accurate."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "{   'cost_function_evals': 241,\n",
      "    'eigenstate': {'01': 1007, '10': 17},\n",
      "    'eigenvalue': (-1.8623464125433034+0j),\n",
      "    'optimal_parameters': {   Parameter(θ[3]): 7.149874669811867,\n",
      "                              Parameter(θ[7]): -1.8648388048829714,\n",
      "                              Parameter(θ[2]): 2.146860065695897,\n",
      "                              Parameter(θ[1]): 2.0047037904408738,\n",
      "                              Parameter(θ[5]): 0.026059065222908795,\n",
      "                              Parameter(θ[6]): -4.4426207121597745,\n",
      "                              Parameter(θ[4]): -4.6685058886658455,\n",
      "                              Parameter(θ[0]): 4.731406884288576},\n",
      "    'optimal_point': array([ 4.73140688,  2.00470379,  2.14686007,  7.14987467, -4.66850589,\n",
      "        0.02605907, -4.44262071, -1.8648388 ]),\n",
      "    'optimal_value': -1.8623464125433034,\n",
      "    'optimizer_time': 11.047632932662964}\n"
     ]
    }
   ],
   "source": [
    "from qiskit.aqua.components.optimizers import SPSA\n",
    "\n",
    "aqua_globals.random_seed = seed\n",
    "qi = QuantumInstance(Aer.get_backend('qasm_simulator'), seed_transpiler=seed, seed_simulator=seed)\n",
    "\n",
    "ansatz = TwoLocal(rotation_blocks='ry', entanglement_blocks='cz')\n",
    "slsqp = SPSA(maxiter=100)\n",
    "vqe = VQE(operator=H2_op, var_form=ansatz, optimizer=slsqp, quantum_instance=qi)\n",
    "result = vqe.run()\n",
    "\n",
    "pp.pprint(result)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "As mentioned above, an expectation object can be explicitly given (so the internal `ExpectationFactory` and include_custom are never used/needed. Below we create an `AerPauliExpectation` and pass this to VQE. We can see the result matches that above where we set include_custom to True and let VQE create its own expectation object."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "{   'cost_function_evals': 72,\n",
      "    'eigenstate': {'01': 1008, '10': 16},\n",
      "    'eigenvalue': (-1.8572750175597519+0j),\n",
      "    'optimal_parameters': {   Parameter(θ[5]): 1.568326000491598,\n",
      "                              Parameter(θ[6]): -4.717618128585369,\n",
      "                              Parameter(θ[4]): -2.5983258956331645,\n",
      "                              Parameter(θ[2]): 0.5470754235069875,\n",
      "                              Parameter(θ[3]): 6.092947836794945,\n",
      "                              Parameter(θ[7]): 0.3602072910298268,\n",
      "                              Parameter(θ[0]): 4.296520463599476,\n",
      "                              Parameter(θ[1]): 4.426962139199476},\n",
      "    'optimal_point': array([ 4.29652046,  4.42696214,  0.54707542,  6.09294784, -2.5983259 ,\n",
      "        1.568326  , -4.71761813,  0.36020729]),\n",
      "    'optimal_value': -1.8572750175597519,\n",
      "    'optimizer_evals': 72,\n",
      "    'optimizer_time': 1.3454556465148926}\n"
     ]
    }
   ],
   "source": [
    "from qiskit.aqua.operators import AerPauliExpectation\n",
    "\n",
    "aqua_globals.random_seed = seed\n",
    "qi = QuantumInstance(Aer.get_backend('qasm_simulator'), seed_transpiler=seed, seed_simulator=seed)\n",
    "\n",
    "ansatz = TwoLocal(rotation_blocks='ry', entanglement_blocks='cz')\n",
    "slsqp = SLSQP(maxiter=1000)\n",
    "vqe = VQE(operator=H2_op, var_form=ansatz, optimizer=slsqp, quantum_instance=qi,\n",
    "          expectation=AerPauliExpectation())\n",
    "result = vqe.run()\n",
    "\n",
    "pp.pprint(result)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "By default, the `PauliExpectation` object, that would have be chosen when include_custom is False (or when using BasicAer qasm_simulator, or a real device) groups Paulis into commuting sets. This is efficient as it runs less circuits to compute the expectation. However, if for some reason you wanted to run a circuit for each Pauli then then grouping can be turned off when constructing the PauliExpectation. You need to explicitly pass in such an expectation instance to VQE to have it work this way though as shown below."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "{   'cost_function_evals': 241,\n",
      "    'eigenstate': {'01': 1007, '10': 17},\n",
      "    'eigenvalue': (-1.8667499370593512+0j),\n",
      "    'optimal_parameters': {   Parameter(θ[1]): 2.1216349904032947,\n",
      "                              Parameter(θ[7]): -1.9698662442728732,\n",
      "                              Parameter(θ[5]): 0.2634941452871489,\n",
      "                              Parameter(θ[6]): -4.360567678129973,\n",
      "                              Parameter(θ[0]): 4.718047005792739,\n",
      "                              Parameter(θ[4]): -4.733789920734712,\n",
      "                              Parameter(θ[2]): 2.1876557567510497,\n",
      "                              Parameter(θ[3]): 7.317481602611872},\n",
      "    'optimal_point': array([ 4.71804701,  2.12163499,  2.18765576,  7.3174816 , -4.73378992,\n",
      "        0.26349415, -4.36056768, -1.96986624]),\n",
      "    'optimal_value': -1.8667499370593512,\n",
      "    'optimizer_time': 20.964618682861328}\n"
     ]
    }
   ],
   "source": [
    "from qiskit.aqua.operators import PauliExpectation\n",
    "\n",
    "aqua_globals.random_seed = seed\n",
    "qi = QuantumInstance(Aer.get_backend('qasm_simulator'), seed_transpiler=seed, seed_simulator=seed)\n",
    "\n",
    "ansatz = TwoLocal(rotation_blocks='ry', entanglement_blocks='cz')\n",
    "slsqp = SPSA(maxiter=100)\n",
    "vqe = VQE(operator=H2_op, var_form=ansatz, optimizer=slsqp, quantum_instance=qi,\n",
    "          expectation=PauliExpectation(group_paulis=False))\n",
    "result = vqe.run()\n",
    "\n",
    "pp.pprint(result)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Gradient\n",
    "\n",
    "Optimizers that use a gradient-based technique can be supplied with a user defined gradient that will be used instead of their default gradient computation which is usually done by simple finite difference. Gradients are passed indirectly via to the optimizer via its `gradient` parameter.\n",
    "\n",
    "As the use of a user supplied `gradient` was shown in the [Monitoring VQE Convergence](02_vqe_convergence.ipynb#Using-Gradient-framework) tutorial I will simply refer you there. Also the [Gradients framework](../operators/02_gradients_framework.ipynb) tutorial has much more about the gradients themselves."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Quantum Instance and advanced simulation\n",
    "\n",
    "While you may be familiar with passing a QuantumInstancen created from a `statevector_simulator` a `qasm_simulator` or   real device backend, it is possible to use the advanced simulation modes of Aer too when applicable. For instance we can easily use the Aer [Matrix Product State](../simulators/7_matrix_product_state_method.ipynb) method, that has the potential to scale to larger numbers of qubits."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "{   'cost_function_evals': 72,\n",
      "    'eigenstate': {'01': 1008, '10': 16},\n",
      "    'eigenvalue': (-1.8572750175597519+0j),\n",
      "    'optimal_parameters': {   Parameter(θ[0]): 4.296520463599476,\n",
      "                              Parameter(θ[6]): -4.717618128585369,\n",
      "                              Parameter(θ[7]): 0.3602072910298268,\n",
      "                              Parameter(θ[4]): -2.5983258956331645,\n",
      "                              Parameter(θ[5]): 1.568326000491598,\n",
      "                              Parameter(θ[3]): 6.092947836794945,\n",
      "                              Parameter(θ[2]): 0.5470754235069875,\n",
      "                              Parameter(θ[1]): 4.426962139199476},\n",
      "    'optimal_point': array([ 4.29652046,  4.42696214,  0.54707542,  6.09294784, -2.5983259 ,\n",
      "        1.568326  , -4.71761813,  0.36020729]),\n",
      "    'optimal_value': -1.8572750175597519,\n",
      "    'optimizer_evals': 72,\n",
      "    'optimizer_time': 1.2383882999420166}\n"
     ]
    }
   ],
   "source": [
    "aqua_globals.random_seed = seed\n",
    "\n",
    "from qiskit.providers.aer import QasmSimulator\n",
    "quantum_instance = QuantumInstance(QasmSimulator(method='matrix_product_state'), shots=1)\n",
    "\n",
    "ansatz = TwoLocal(rotation_blocks='ry', entanglement_blocks='cz')\n",
    "slsqp = SLSQP(maxiter=1000)\n",
    "vqe = VQE(operator=H2_op, var_form=ansatz, optimizer=slsqp, quantum_instance=qi, include_custom=True)\n",
    "result = vqe.run()\n",
    "\n",
    "pp.pprint(result)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<h3>Version Information</h3><table><tr><th>Qiskit Software</th><th>Version</th></tr><tr><td>Qiskit</td><td>0.23.1</td></tr><tr><td>Terra</td><td>0.16.1</td></tr><tr><td>Aer</td><td>0.7.1</td></tr><tr><td>Ignis</td><td>0.5.1</td></tr><tr><td>Aqua</td><td>0.8.1</td></tr><tr><td>IBM Q Provider</td><td>0.11.1</td></tr><tr><th>System information</th></tr><tr><td>Python</td><td>3.6.1 |Continuum Analytics, Inc.| (default, May 11 2017, 13:09:58) \n",
       "[GCC 4.4.7 20120313 (Red Hat 4.4.7-1)]</td></tr><tr><td>OS</td><td>Linux</td></tr><tr><td>CPUs</td><td>1</td></tr><tr><td>Memory (Gb)</td><td>5.827335357666016</td></tr><tr><td colspan='2'>Tue Nov 17 15:48:57 2020 EST</td></tr></table>"
      ],
      "text/plain": [
       "<IPython.core.display.HTML object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/html": [
       "<div style='width: 100%; background-color:#d5d9e0;padding-left: 10px; padding-bottom: 10px; padding-right: 10px; padding-top: 5px'><h3>This code is a part of Qiskit</h3><p>&copy; Copyright IBM 2017, 2020.</p><p>This code is licensed under the Apache License, Version 2.0. You may<br>obtain a copy of this license in the LICENSE.txt file in the root directory<br> of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.<p>Any modifications or derivative works of this code must retain this<br>copyright notice, and modified files need to carry a notice indicating<br>that they have been altered from the originals.</p></div>"
      ],
      "text/plain": [
       "<IPython.core.display.HTML object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "import qiskit.tools.jupyter\n",
    "%qiskit_version_table\n",
    "%qiskit_copyright"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.1"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
